#ifndef __BUOLA_GUI_CPHYSICALWINDOW_H__
#define __BUOLA_GUI_CPHYSICALWINDOW_H__

#include <buola/gui/cwindow.h>
#include <buola/image/csurface.h>

namespace buola { namespace gui {

///\addtogroup gui
///@{

///////////////////////////////////////////////////////////////////////////

/// physical window

/// objects of this class represent a window in the underlying windowing
/// system, such as an Xlib window
///
///////////////////////////////////////////////////////////////////////////

class CPhysicalWindow : public img::CSurface
{
public:
//! \name constructor and destructor
//@{
    CPhysicalWindow(const PWindow &pWindow);
    virtual ~CPhysicalWindow();
//@}

public:
//! \name window creation and destruction
//@{
    //! from window information
    virtual void Create(CPhysicalWindow *pParent,const CPoint_d &pPos,const CSize_d &pSize)=0;
    //! destroy the window
    virtual void Destroy()=0;
//@}

//! \name direct protocol access
//! These functions provide direct access to the functionality of the
//! particular window environment. They should only be used by low-level
//! code.
//@{
    virtual void ClearArea(const CRect_i &pRect,bool)=0;
    virtual void Map(bool pRaise)=0;
    virtual void Unmap()=0;
    virtual void Reparent(CPhysicalWindow*,const CPoint_d&)=0;
    virtual void Lower()=0;
    virtual void Raise(const std::vector<CPhysicalWindow*> &pExc)=0;
    virtual void StayOnTop(CPhysicalWindow *pOther)=0;
    virtual void SelectInput(EEvents pEvents)=0;
    virtual void SetGravity(int)=0;
    virtual void SetBackingStore(bool)=0;
    virtual void SetNoShape(int=SHAPE_BOUND)=0;
    virtual void SetShape(const CRegion &pRegion,int=SHAPE_BOUND,
                                const CPoint_d& =CPoint_d(nZero))=0;
    virtual void SetShapeFromMask(img::CSurface *pMask,int=SHAPE_BOUND,
                                const CPoint_d& =CPoint_d(nZero))=0;
    virtual void SetShapeFromRect(const CRect_d&,int=SHAPE_BOUND,
                                const CPoint_d& =CPoint_d(nZero))=0;
    virtual void SetShapeFromWindow(CPhysicalWindow *pWindow,int=SHAPE_BOUND,
                                const CPoint_d& =CPoint_d(nZero))=0;
    virtual void SetPointer(PPointer pPointer)=0;
//@}

//! \name window embedding
//@{
    virtual void Embed(CPhysicalWindow *pChild)=0;
//@}

//! \name button grabbing
//@{
    virtual void GrabButton(EMouseButton pButton,EKeyMod pMods,
                    bool pConfine,CPointer *pCursor)=0;
    virtual void UngrabButton(EMouseButton pButton,EKeyMod pMods)=0;
//@}

//! \name geometry
//@{
    virtual void Move(const CPoint_d&)=0;
    virtual void Resize(const CSize_d&)=0;
    virtual void MoveResize(const CPoint_d&,const CSize_d&)=0;

    virtual CPoint_d TranslateCoords(const CPoint_d &pPoint,CPhysicalWindow *pWindow)=0;

    virtual void SetFocus()=0;
//@}

    virtual CExposeHelper *GetExposeHelper()=0;
    
//! \name event management
//@{
    virtual void DispatchAll()=0;
//@}


//! \name window-management
//@{
    virtual void Freeze(bool pFrozen)=0;
    virtual EWindowState GetState()=0;
    virtual void Iconify(bool)=0;
    virtual void Maximize(EWindowState)=0;
    virtual void Shade(bool)=0;
    virtual void Sticky(bool)=0;
    virtual void SetDesktop(int)=0;
    virtual void FullScreen(bool)=0;
    virtual void StartMoveOperation(CMouseEvent *pE)=0;
    virtual void StartResizeOperation(CMouseEvent *pE,EDragState pType)=0;
    virtual void SetStrut(const CRect_d &pRect)=0;
    virtual void SetOpacity(double pOpacity)=0;
    virtual void SetTitle(const std::wstring &pTitle)=0;
    virtual void SetIcon(PIcon pIcon)=0;
//@}

public:
//! \name information
//@{
    const CSize_d &GetSize()          {   return mSize;       }
    const CPoint_d &GetPos()          {   return mPos;        }
//@}

public:
    const PWindow &GetWindow()          {   return mWindow;     }

protected:
//! \name internal data
//@{
    PWindow mWindow;

    CPoint_d mPos;
    CSize_d mSize;
//@}
};

///@}

/*namespace gui*/ } /*namespace buola*/ }

#endif
